<template>
<div class="pwd">
  <h2>修改密码</h2>
  <ul>
    <li>
      <span><i>*</i><b>原密码</b></span>
      <el-input v-model="oldPwd"></el-input>
    </li>
    <li>
      <span><i>*</i><b>新密码</b></span>
      <el-input v-model="newPwd"></el-input>
    </li>
    <li>
      <span><i>*</i><b>确认密码</b></span>
      <el-input v-model="rptPwd"></el-input>
    </li>
  </ul>
  <li class="save">
    <el-button type="primary" @click="save">保存</el-button>
  </li>

</div>
</template>

<script>
    export default {
        data(){
          return{
            oldPwd:'',
            newPwd:'',
            rptPwd:''
          }
        },
      methods:{
        save(){
          if(this.oldPwd == ''){
            this.$message.warning('原密码不能为空')
          }else if(this.newPwd == ''){
            this.$message.warning('新密码不能为空')
          }else if(this.rptPwd != this.newPwd){
            this.$message.warning('两次输入不一致,请重新输入')
          }else if(!/^[\da-zA-Z]{6,16}$/.test(this.newPwd)){
            this.$message.warning('请输入6-16为字母、数字及组合类型密码')
          }else {
            this.$message.success('密码已修改,请牢记新密码')
          }
        }
      }
    }
</script>

<style scoped lang="scss">
.pwd{
  width: 100%;
  text-align: left;
  padding-left: 10px;
  h2{
    font-size: 26px;
    margin: 30px 0;
  }
  ul{
    display: flex;
    flex-direction: column;
    li{
      display: flex;
      flex-direction: column;
      span{
        font-size: 20px;
        i{
          font-size: 20px;
          color: orangered;
        }
        b{
          font-weight: normal;
        }
      }
      .el-input{
        margin: 10px 0;
        width: 500px;
      }
    }
  }
  .save{
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 500px;
    .el-button{
      padding: 10px 30px ;
      letter-spacing: 2px;
      margin: 50px 150px;
    }
  }

}
</style>
